<?php
namespace App\Admin\Controllers\Operation;

use App\Models\Basics\AmazonCountry;;
use App\Models\Operation\AdsVC;
use App\Models\Product\ProductClassify;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Grid;
class ADSVCController extends AdminController{

    protected $title = '视频广告数据';

    protected function grid()
    {
        $grid = new Grid(new AdsVC());
        $grid->model()->orderBy('id', 'DESC');
        $grid->column('id','ID')->totalRow('ALL');
        $grid->column('report_date','报表日期');
        $grid->column('country.country','国家');
        $grid->column('sku.psku_code','SKU');
        $grid->column('classify.title','品类');
        $grid->column('impressions','Impressions')->totalRow();
        $grid->column('clicks','Clicks')->totalRow();
        $grid->column('total_units','广告订单数')->totalRow();
        $grid->column('spend','广告费用')->totalRow();
        $grid->column('total_sales','广告销售额')->totalRow();
        $grid->disableActions();
        $grid->disableExport();
        $grid->disableCreateButton();
        $grid->disableRowSelector();
        $grid->filter(function($filter){
            $filter->column(1/3, function ($filter) {
                $filter->between('report_date', '日期')->datetime();
            });
            $filter->column(1/3, function ($filter) {
                $filter->equal('country_id','国家')->select(AmazonCountry::options());
            });
            $filter->column(1/3, function ($filter) {
                $filter->equal('classify_id','品类')->select(ProductClassify::options());
            });
        });
        return $grid;
    }
}
